import request from '@/utils/request'

/**
 * 获取用户列表
 * @param {{
 *  status: string
 *  keyword: string
 *  tel: string
 * }} data
 * @returns
 */
export function menuList(data) {
  return request({
    url: '/member.menu',
    method: 'post',
    data
  })
}

/**
 * @typedef {{
 *  menu_pid: number
 *  menu_name: string
 *  route_path: string
 *  redirect: string
 *  route_api: string
 *  hidden: number
 *  affix: number
 *  status: DEFAULT_SWITCH_VALUE
 *  menu_type: number
 *  icon_name: string
 *  sort: number
 * }} TMenuUpdateParams
 */

/**
 * 添加菜单
 * @param {TMenuUpdateParams} data
 * @returns
 */
export function createMenu(data) {
  return request({
    url: '/member.menu/handleAdd',
    method: 'post',
    data
  })
}

/**
 * 编辑菜单
 * @param {{
 *  menu_id: number
 * } & TMenuUpdateParams} data
 * @returns
 */
export function editMenu(data) {
  return request({
    url: '/member.menu/handleEdit',
    method: 'post',
    data
  })
}

/**
 * 删除菜单
 * @param {{
 *  menu_id: number
 *  menu_name: string
 *  status: DEFAULT_SWITCH_VALUE
 * }} data
 * @returns
 */
export function deleteMenu(data) {
  return request({
    url: '/member.menu/handleDel',
    method: 'post',
    data
  })
}

/**
 * 改变状态
 * @param {{
 *  menu_id: number
 *  menu_name: string
 *  status: DEFAULT_SWITCH_VALUE
 * }} data
 * @returns
 */
export function changeStatus(data) {
  return request({
    url: '/member.menu/handleStatus',
    method: 'post',
    data
  })
}

